from ext import db

class BookModel(db.Model):
    __tablename__ = 'book'
    id = db.Column(db.Integer,primary_key=True,autoincrement=True)
    name = db.Column(db.String(128),comment='书名e')
    price = db.Column(db.Float(precision=2),comment='价格')
    author_id = db.Column(db.Integer,db.ForeignKey('author.id'))
    author = db.relationship('AuthorModel',backref='books',lazy=True)


class AuthorModel(db.Model):
    __tablename__ = 'author'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(128), comment='作者名')
    address = db.Column(db.String(128), comment='地址')
    phone = db.Column(db.String(16),comment='手机号码')
    date = db.Column(db.Date,comment='日期')
    datetime = db.Column(db.DateTime,comment='日期时间')